﻿using System;
namespace Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="IsikOtsing", Namespace="http://producers.etoimik.xtee.riik.ee/producer/etoimik", Target=typeof(IsikOtsing))]
    public class IsikOtsingSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IIsikOtsing clazz;
        
        public IsikOtsingSerializer(IIsikOtsing clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.EXCLUDE!=null) {
                Writer.WriteStartElement("EXCLUDE");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "boolean");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdBoolean(((bool)(clazz.EXCLUDE))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.ObjektID!=null) {
                Writer.WriteStartElement("ObjektID");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.ObjektID))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Kood!=null) {
                Writer.WriteStartElement("Kood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Kood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Koosnimi!=null) {
                Writer.WriteStartElement("Koosnimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Koosnimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.EelmisedKoosnimedCSV!=null) {
                Writer.WriteStartElement("EelmisedKoosnimedCSV");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EelmisedKoosnimedCSV))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Nimi!=null) {
                Writer.WriteStartElement("Nimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Nimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MenetlusSubjektiLiikKL!=null) {
                Writer.WriteStartElement("MenetlusSubjektiLiikKL");
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("long", "http://www.w3.org/2001/XMLSchema", clazz.MenetlusSubjektiLiikKL.Count);
                for (int x = 0; ((clazz.MenetlusSubjektiLiikKL != null) 
                            && (x < clazz.MenetlusSubjektiLiikKL.Count)); x = (x + 1)) {
                    if (clazz.MenetlusSubjektiLiikKL[x]!=null) {
                        Writer.WriteStartElement("item");
                        Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                        Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.MenetlusSubjektiLiikKL[x]))).ToString());
                        Writer.WriteEndElement();
                    }
                }
                Writer.WriteEndElement();
            }
            if (clazz.MuudeRiikideKoodid!=null) {
                Writer.WriteStartElement("MuudeRiikideKoodid");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.MuudeRiikideKoodid))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OsalineKL!=null) {
                Writer.WriteStartElement("OsalineKL");
                Writer.WriteTypeAttribute("http://schemas.xmlsoap.org/soap/encoding/", "Array");
                Writer.WriteArrayTypeAttribute("long", "http://www.w3.org/2001/XMLSchema", clazz.OsalineKL.Count);
                for (int x = 0; ((clazz.OsalineKL != null) 
                            && (x < clazz.OsalineKL.Count)); x = (x + 1)) {
                    if (clazz.OsalineKL[x]!=null) {
                        Writer.WriteStartElement("item");
                        Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                        Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.OsalineKL[x]))).ToString());
                        Writer.WriteEndElement();
                    }
                }
                Writer.WriteEndElement();
            }
            if (clazz.AinultSysteemsed!=null) {
                Writer.WriteStartElement("AinultSysteemsed");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "boolean");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdBoolean(((bool)(clazz.AinultSysteemsed))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="EXCLUDE") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>IsikOtsing>EXCLUDE");
                }
                clazz.EXCLUDE = new global::Xtee.Core.Schema.XsdBoolean(Reader.ReadElementString("EXCLUDE")).Value;
            }
            if (Reader.LocalName=="ObjektID") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>IsikOtsing>ObjektID");
                }
                clazz.ObjektID = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("ObjektID")).Value;
            }
            if (Reader.LocalName=="Kood") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Kood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Kood")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Koosnimi") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Koosnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Koosnimi")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="EelmisedKoosnimedCSV") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.EelmisedKoosnimedCSV = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("EelmisedKoosnimedCSV")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Nimi") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Nimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Nimi")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="MenetlusSubjektiLiikKL") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MenetlusSubjektiLiikKL = new System.Collections.Generic.List<System.Int64?>();
                    if ((Reader.IsEmptyElement == false)) {
                        Reader.ReadStartElement("MenetlusSubjektiLiikKL");
                        for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                    && (Reader.LocalName == "item")); ) {
                            if (Reader.IsElementNil()) {
                                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>IsikOtsing>MenetlusSubjektiLiikKL>item");
                            }
                            clazz.MenetlusSubjektiLiikKL.Add(new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("item")).Value);
                        }
                        Reader.ReadEndElement();
                    }
                    else {
                        Reader.Skip();
                    }
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="MuudeRiikideKoodid") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MuudeRiikideKoodid = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("MuudeRiikideKoodid")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="OsalineKL") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.OsalineKL = new System.Collections.Generic.List<System.Int64?>();
                    if ((Reader.IsEmptyElement == false)) {
                        Reader.ReadStartElement("OsalineKL");
                        for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                                    && (Reader.LocalName == "item")); ) {
                            if (Reader.IsElementNil()) {
                                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>>IsikOtsing>OsalineKL>item");
                            }
                            clazz.OsalineKL.Add(new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("item")).Value);
                        }
                        Reader.ReadEndElement();
                    }
                    else {
                        Reader.Skip();
                    }
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="AinultSysteemsed") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>IsikOtsing>AinultSysteemsed");
                }
                clazz.AinultSysteemsed = new global::Xtee.Core.Schema.XsdBoolean(Reader.ReadElementString("AinultSysteemsed")).Value;
            }
        }
    }
}
